<?php

require_once 'ComponentBase.php';

/**
 * Description of AuthenticationComponent
 *
 * @author JeyDotC
 */
class AuthenticationComponent extends ComponentBase {

    /**
     *
     * @param string $user
     * @param string $pass
     * @return bool 
     */
    function login($user, $pass) {
        /* @var $response Response */
        $response = $this->Autenticacion->Login($user, $pass);
        
        $succeed = $response->getSuccess();
        
        if ($succeed) {

            $permisions = array();

            foreach ($response->getData() as /* @var $role Roles */$role) {
                $permisions[] = $role->getNombre();
            }

            ModulesContext::instance()->getSession()->put("__Principal", array(
                "name" => $user,
                "credential" => $pass,
                "permissions" => $permisions
            ));
        }
        
        return $succeed;
    }

}

?>
